// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import DataMgr from "./common/DataMgr";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    _win_view: fgui.GComponent;

    _integral_view: fgui.GLabel;

    // LIFE-CYCLE CALLBACKS:
    // use this for initialization

    onLoad() {
        fgui.addLoadHandler();

        fgui.GRoot.create();

        fgui.UIPackage.loadPackage("UI/IMGame", this.onUILoaded.bind(this));
    }

    onUILoaded() {
        // fgui.UIPackage.addPackage("UI/IMGame");

        this._win_view = fgui.UIPackage.createObject("IMGame", "WinPanel").asCom;
        this._win_view.makeFullScreen();
        // this._integral_view.visible=false;

        //积分
        this._win_view.getChild("n13").onClick(this.onReStartClick, this);
        this._win_view.getChild("n20").onClick(this.onBackClick, this);

        fgui.GRoot.inst.addChild(this._win_view);
    }

    onBackClick(){
        
    }


    //点击重新开始按钮
    onReStartClick() {
        // DataMgr.reset();
        cc.director.loadScene('game');
    }

    //点击放弃按钮
    onGiveUpClick() {
        cc.sys.localStorage.setItem('level', 1);
        // DataMgr.reset();
        cc.director.loadScene('start');
        // console.log("onGiveUpClick");
    }

    start() {

    }
}
